{
 "cells": [
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.561186Z",
     "start_time": "2025-09-28T14:16:40.556489Z"
    }
   },
   "source": [
    "import numpy as np\n",
    "arr1d=np.array([1,2,3])\n",
    "arr1d"
   ],
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1, 2, 3])"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 83
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.582583Z",
     "start_time": "2025-09-28T14:16:40.578562Z"
    }
   },
   "cell_type": "code",
   "source": [
    "arr2d=np.array([[1,2,3],[4,5,6]])\n",
    "arr2d"
   ],
   "id": "e4aa4d47f376187",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 2, 3],\n",
       "       [4, 5, 6]])"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 84
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.597696Z",
     "start_time": "2025-09-28T14:16:40.593469Z"
    }
   },
   "cell_type": "code",
   "source": [
    "arr3d=np.array([[[1,2,3],[4,5,6]],[[7,8,9],[1,2,3]]])\n",
    "arr3d"
   ],
   "id": "c67bb0917b82db08",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[1, 2, 3],\n",
       "        [4, 5, 6]],\n",
       "\n",
       "       [[7, 8, 9],\n",
       "        [1, 2, 3]]])"
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 85
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.608839Z",
     "start_time": "2025-09-28T14:16:40.605224Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a1=np.zeros((3,3))\n",
    "a1"
   ],
   "id": "a0887c313f931202",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0., 0., 0.],\n",
       "       [0., 0., 0.],\n",
       "       [0., 0., 0.]])"
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 86
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.620879Z",
     "start_time": "2025-09-28T14:16:40.616328Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a2=np.ones((3,3))\n",
    "a2"
   ],
   "id": "16fb0ae87f62c877",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 1., 1.],\n",
       "       [1., 1., 1.],\n",
       "       [1., 1., 1.]])"
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 87
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.630423Z",
     "start_time": "2025-09-28T14:16:40.626937Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a3=np.eye(3)\n",
    "a3"
   ],
   "id": "79140a7242a1ee74",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.]])"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 88
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.643410Z",
     "start_time": "2025-09-28T14:16:40.639849Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a4=np.empty((3,3))\n",
    "a4"
   ],
   "id": "d65a8a1ae215d558",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 0., 0.],\n",
       "       [0., 1., 0.],\n",
       "       [0., 0., 1.]])"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 89
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.655388Z",
     "start_time": "2025-09-28T14:16:40.651545Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a5=np.arange(1,20,5)#起始为1，终止为20，步长为5\n",
    "a5"
   ],
   "id": "3f50771871e939b0",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 1,  6, 11, 16])"
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 90
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.679379Z",
     "start_time": "2025-09-28T14:16:40.675377Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a5=np.linspace(1,20,5)\n",
    "a5"
   ],
   "id": "b3fda590c2d0eb4b",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 1.  ,  5.75, 10.5 , 15.25, 20.  ])"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 91
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.694551Z",
     "start_time": "2025-09-28T14:16:40.690192Z"
    }
   },
   "cell_type": "code",
   "source": [
    "a6=np.ones((3,3),dtype='int32')\n",
    "a6"
   ],
   "id": "e63582c5c1bed91f",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1, 1, 1],\n",
       "       [1, 1, 1],\n",
       "       [1, 1, 1]], dtype=int32)"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 92
  },
  {
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-09-28T14:16:40.726718Z",
     "start_time": "2025-09-28T14:16:40.720885Z"
    }
   },
   "cell_type": "code",
   "source": [
    "float_data=arr2d.astype(np.float32)\n",
    "float_data.dtype.name"
   ],
   "id": "fc082a7ba056e3cf",
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'float32'"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "execution_count": 93
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:liuyinuo]",
   "language": "python",
   "name": "conda-env-liuyinuo-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
